package com.lwm.newdate;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author liweimin
 * @date 2020/9/15 15:17
 * @description
 */
public class SimpleDateFormatTest {
    @Test
    public void test01(){
        Callable<Date> dateCallable = new Callable<Date>(){
            @Override
            public Date call() throws Exception {
                return ThreadLocalDemo.convert("20200916");
            }
        };
        ExecutorService pool = Executors.newFixedThreadPool(10);
        List<Future<Date>> list = new ArrayList<>();
        for (int i = 0; i < 10 ; i++) {
            list.add(pool.submit(dateCallable));
        }
        list.forEach(e->{
            try {
                System.out.println(e.get());
            } catch (InterruptedException interruptedException) {
                interruptedException.printStackTrace();
            } catch (ExecutionException executionException) {
                executionException.printStackTrace();
            }
        });
        pool.shutdown();
    }
}
